#pragma once

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <memory>
#include "context_common.h"
#include "framework/input.h"

namespace cyb
{

class Context_WGL
{
public:
	Context_WGL();
	~Context_WGL() = default;

	void Create( uint32_t width, uint32_t height );
	void Destroy();
	
	bool Valid() const;
	void SwapBuffers();

private:
	HWND m_hwnd;
	HDC m_hdc;
	HGLRC m_hglrc;
};

class Context_Win : public Context_Common
{
public:
	Context_Win( const Dimension2i& resolution );
	virtual ~Context_Win();

	void OpenWindow();
	LRESULT WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );

	void OnMsgProc( UINT uMsg, WPARAM wParam, LPARAM lParam, std::shared_ptr<InputListener> inupt );
	virtual void ProcessEvents();
	virtual bool IsOpen() { return m_isOpen; }
	virtual void Title( const std::string& windowTitle );
	virtual void ShowMouseCursor( bool show );
	virtual void Resize( const Dimension2i& resolution );
	virtual void SwapBuffers();

private:
	Dimension2i m_resolution;
	InputListenerList m_inputListerners;
	HWND m_hwnd;
	HDC m_hdc;
	HGLRC m_hglrc;
	bool m_isOpen;
};

}	// namespace cyb